/*
 * Copyright (c) 2003-2004, Inversoft, All Rights Reserved
 */
package org.emergent.antbite.savant.ant.types;


import java.util.List;
import java.util.Set;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.DataType;

import org.emergent.antbite.savant.Dependencies;
import org.emergent.antbite.savant.SavantException;


/**
 * <p>
 * This class is the ant DataType proxy to the
 * {@link Dependencies} class.
 * </p>
 *
 * @author Brian Pontarelli
 */
public class DependenciesType extends DataType {
    private Dependencies proxy = new Dependencies();


    /**
     * Adds the given artifact group to the list of artifact groups in this list
     * of dependencies.
     *
     * @param   group The group to add
     */
    public void addConfiguredArtifactGroup(ArtifactGroupType group) {
        try {
            proxy.addArtifactGroup(group.getProxy());
        } catch (SavantException se) {
            throw new BuildException(se);
        }
    }

    /**
     * Removes the given artifact group to the list of artifact groups in this
     * dependency.
     *
     * @param   group The group to remove
     */
    public void removeArtifactGroup(ArtifactGroupType group) {
        proxy.removeArtifactGroup(group.getProxy());
    }

    /**
     * Adds the given artifact to the list of artifacts in this list of Dependencies.
     *
     * @param   artifact The artifact to add
     */
    public void addConfiguredArtifact(ArtifactType artifact) throws SavantException {
        try {
            proxy.addArtifact(artifact.getProxy());
        } catch (SavantException se) {
            throw new BuildException(se);
        }
    }

    /**
     * Removes the given artifact to the list of artifact in this dependency.
     *
     * @param   artifact The artifact to remove
     */
    public void removeArtifact(ArtifactType artifact) {
        proxy.removeArtifact(artifact.getProxy());
    }

    /**
     * Returns the artifact group list. This is list immutable.
     */
    public List getArtifactGroups() {
        return proxy.getArtifactGroups();
    }

    /**
     * Returns the artifact list. This List is immutable.
     */
    public List getArtifacts() {
        return proxy.getArtifacts();
    }

    /**
     * Returns the Set of artifacts contained here or in ArtifactGroups within.
     */
    public Set getAllArtifacts() {
        return proxy.getAllArtifacts();
    }
}